1include <BOSL2/std.scad>
2
3stamp_dimensions = [ 2.3*3, 3.2*3, 30*3 ];
4
5mount_length_dimensions = [ 1.5*3, 4*3, 0.8*3 ];
6mount_width_dimensions = [ 0.8*3, 1.4*3, 0.6*3 ];
7mount_width_offset_from_middle = 8*3;
8
9rounding = 0.2*3;
10rounding_length = 0.3*3;
11rounding_width = 0.1*3;
12
13tolerance = 0.1;
14
15text_font = "Noto Sans CJK JP:style=Bold";
16text_size = 1.25*3;
17text_stamp_depth = 1*3;
18text_legend_depth = 1*3;
19
20resolution = 32;
21
22module outer_length_mounts()
23{
24 translate([ stamp_dimensions.x / 2 - (mount_length_dimensions.z - tolerance) / 2, stamp_dimensions.y / 2, 0 ])
25 length_mount();
26 translate([ -stamp_dimensions.x / 2 + (mount_length_dimensions.z - tolerance) / 2, stamp_dimensions.y / 2, 0 ])
27 length_mount();
28}
29
30module inner_length_mounts()
31{
32 translate([ stamp_dimensions.x / 2 - (mount_length_dimensions.z + tolerance) / 2, -stamp_dimensions.y / 2, 0 ])
33 length_mount(true);
34 translate([ -stamp_dimensions.x / 2 + (mount_length_dimensions.z + tolerance) / 2, -stamp_dimensions.y / 2, 0 ])
35 length_mount(true);
36}
37
38module outer_width_mounts()
39{
40 translate([ stamp_dimensions.x / 2, 0, mount_width_offset_from_middle ]) width_mount();
41 translate([ stamp_dimensions.x / 2, 0, -mount_width_offset_from_middle ]) width_mount();
42}
43
44module inner_width_mounts()
45{
46 translate([ -stamp_dimensions.x / 2, 0, mount_width_offset_from_middle ]) width_mount(true);
47 translate([ -stamp_dimensions.x / 2, 0, -mount_width_offset_from_middle ]) width_mount(true);
48}
49
50module stamp(text_character = "0")
51{
52 difference()
53 {
54 union()
55 {
56 cuboid(stamp_dimensions, rounding = rounding, $fn = resolution / 4);
57 outer_length_mounts();
58 outer_width_mounts();
59 translate([ 0, 0, -stamp_dimensions.z / 2 - text_stamp_depth ]) linear_extrude(text_stamp_depth)
60 text(text_character, text_size, text_font, halign = "center", valign = "center", $fn = resolution);
61 }
62 inner_length_mounts();
63 inner_width_mounts();
64 translate([ 0, 0, stamp_dimensions.z / 2 - text_legend_depth ]) linear_extrude(text_legend_depth)
65 text(text_character, text_size, text_font, halign = "center", valign = "center", $fn = resolution);
66 }
67}
68
69module length_mount(inner = false)
70{
71 if (inner)
72 {
73 scale([ 1, mount_length_dimensions.x + tolerance / 2, mount_length_dimensions.y + tolerance / 2 ])
74 xcyl(l = mount_length_dimensions.z++ tolerance, r = 1, $fn = resolution, rounding = rounding_length);
75 }
76 else
77 {
78 scale([ 1, mount_length_dimensions.x - tolerance / 2, mount_length_dimensions.y - tolerance / 2 ])
79 xcyl(l = mount_length_dimensions.z - tolerance, r = 1, $fn = resolution, rounding = rounding_length);
80 }
81}
82
83module width_mount(inner = false)
84{
85 if (inner)
86 {
87 scale([ mount_width_dimensions.x + tolerance / 2, 1, mount_width_dimensions.y + tolerance / 2 ])
88 ycyl(l = mount_width_dimensions.z++ tolerance, r = 1, $fn = resolution, rounding = rounding_width);
89 }
90 else
91 {
92 scale([ mount_width_dimensions.x - tolerance / 2, 1, mount_width_dimensions.y - tolerance / 2 ])
93 ycyl(l = mount_width_dimensions.z - tolerance, r = 1, $fn = resolution, rounding = rounding_width);
94 }
95}
96